﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

public partial class DocPassWord : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void BtnDL_Click(object sender, EventArgs e)
    {
        Response.Redirect("Logon.aspx");
    }

    protected void BtnYZ_Click(object sender, EventArgs e)
    {
        string sql = string.Format("select * from Doctor where ID='{0}'", this.TxtID.Text);
        SqlDataReader rea = DBHelper.GetDataReader(sql);
        string DocName = "";
        string DocIDCard = "";
        while (rea.Read())
        {
            DocName = rea["Name"].ToString();
            DocIDCard = rea["IDCard"].ToString();
        }
        rea.Close();
        if (TxtName.Text != "" && TxtID.Text != "" && TxtCardID.Text != "")
        {
            if (this.TxtCardID.Text == DocIDCard && this.TxtName.Text == DocName)
            {
                Response.Write("<script> alert('信息验证成功，请输入新密码。')</script>");
                this.BtnXGMM.Enabled = true;
                this.TxtPad.Enabled = true;
            }
        }
        else
        {
            Response.Write("<script> alert('信息验证失败，无法修改密码，请重新输入信息。')</script>");
            this.TxtCardID.Text = "";
            this.TxtName.Text = "";
            this.TxtID.Text = "";
        }
    }

    protected void BtnXGMM_Click(object sender, EventArgs e)
    {
        string updatesql = string.Format("update Doctor set PassWord='{0}'where ID='{1}' ", this.TxtPad.Text, this.TxtID.Text);
        DBHelper.GetNonQuery(updatesql);
        Response.Write("<script> alert('修改成功!') </script>");
        this.TxtName.Text = "";
        this.TxtCardID.Text = "";
        this.TxtID.Text = "";
        this.TxtPad.Text = "";
    }
}